package com.hs.chd.catagory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.hs.params.ParamsCacheUtil;

public class SubjectUtil {
    
	private static SubjectUtil sutil = new SubjectUtil();
	//文章中主题词
	private Map paperkeyWordMap = new HashMap(); 
	
	private ParamsCacheUtil pcu = ParamsCacheUtil.getInst();
	
	public static SubjectUtil getInst(){
		if(null == sutil)
			sutil = new SubjectUtil();
		return sutil;
	}
	/**
	 * 切分文献的主题词
	 * @param pid
	 * @param keywordstr
	 * @param ptype
	 */
	public List splitSubjectStr(String pid,String keywordstr,String ptype){
		paperkeyWordMap.clear();
		List tagslist = new ArrayList();
		if(StringUtils.isNotEmpty( keywordstr )){
			String[] keywords = keywordstr.split(";");
			for(int i = 0 ;i< keywords.length;i++){
				String temp = keywords[i];
				if(StringUtils.isNotEmpty(temp)){
					System.out.println("关键词替换前：" + temp);
					temp = temp.replaceAll("/", "");
					temp = temp.replaceAll("\\*", "");
					System.out.println("关键词替换后：" + temp);
					Map tag = catulateKeyword(temp);
					System.out.println("tags:" +tag);
					tagslist.add(tag);
				}
			}
		}
		return tagslist;
	}
	
	public Map catulateKeyword(String keyword){
		if(null != pcu){
			return (Map)pcu.getIdBytagName(keyword);
		}
		return null;
	}
	
	
	
	
	
	
	
   
}
